﻿CREATE TABLE [dim].[Unit] (
    [UnitUId]                           INT                 NOT NULL,
    [UnitId]                            INT                 NOT NULL,
    [UnitUniqueCode]                    CHAR (7)            NOT NULL,
    [UnitCode]                          VARCHAR (5)         NOT NULL,
    [UnitName]                          VARCHAR (50)        NOT NULL,
    [UnitCateryId]                      SMALLINT            NOT NULL,
    [UnitCateryCode]                    CHAR (2)            NOT NULL,
    [UnitCateryName]                    VARCHAR (50)        NOT NULL,
    [UnitMappingPath]                   [sys].[hierarchyid] NOT NULL,
    [UnitMappingLevel]                  BIGINT              NOT NULL,
    [UnitMappingStartDate]              DATE                NOT NULL,
    [UnitMappingEndDate]                DATE                NOT NULL,
    [UnitStartDate]                     DATE                NOT NULL,
    [UnitEndDate]                       DATE                NOT NULL,
    [UnitOrderBy]                       INT                 NOT NULL,
    [IsLatest]                          BIT                 NOT NULL,
    [IsActive]                          BIT                 NOT NULL,
    [IsInternal]                        BIT                 NOT NULL,
    [ParentUnitUId]                     INT                 NULL,
    [ParentUnitId]                      INT                 NULL,
    [ParentUnitUniqueCode]              CHAR (7)            NULL,
    [ParentUnitCode]                    VARCHAR (5)         NULL,
    [ParentUnitName]                    VARCHAR (50)        NULL,
    [ParentUnitCateryId]                SMALLINT            NULL,
    [ParentUnitCateryCode]              CHAR (2)            NULL,
    [ParentUnitCateryName]              VARCHAR (50)        NULL,
    [ParentUnitMappingPath]             [sys].[hierarchyid] NULL,
    [ParentUnitMappingLevel]            BIGINT              NULL,
    [ParentUnitMappingStartDate]        DATE                NULL,
    [ParentUnitMappingEndDate]          DATE                NULL,
    [ParentUnitStartDate]               DATE                NULL,
    [ParentUnitEndDate]                 DATE                NULL,
    [ParentUnitOrderBy]                 INT                 NULL,
    [ParentIsLatest]                    BIT                 NULL,
    [ParentIsActive]                    BIT                 NULL,
    [ParentIsInternal]                  BIT                 NULL,
    [LegacyUnitId]                      INT                 NULL,
    [LegacyUnitCode]                    VARCHAR (10)        NULL,
    [LegalEntityUId]                    INT                 NOT NULL,
    [LegalEntityId]                     INT                 NOT NULL,
    [LegalEntityUniqueCode]             CHAR (7)            NULL,
    [LegalEntityCode]                   VARCHAR (5)         NULL,
    [LegalEntityName]                   VARCHAR (50)        NULL,
    [LegalEntityOrderBy]                INT                 NULL,
    [DivisionUId]                       INT                 NULL,
    [DivisionId]                        INT                 NULL,
    [DivisionUniqueCode]                CHAR (7)            NULL,
    [DivisionCode]                      VARCHAR (5)         NULL,
    [DivisionName]                      VARCHAR (50)        NULL,
    [DivisionDescription]               NVARCHAR (1000)     NULL,
    [DivisionFlashPnLMinThresholdGBP]   DECIMAL (18, 2)     NULL,
    [DivisionFlashPnLMaxThresholdGBP]   DECIMAL (18, 2)     NULL,
    [DivisionFlashManualUpload]         BIT                 NULL,
    [DivisionFlashMurexUpload]          BIT                 NULL,
    [DivisionOrderBy]                   INT                 NULL,
    [BusinessUId]                       INT                 NULL,
    [BusinessId]                        INT                 NULL,
    [BusinessUniqueCode]                CHAR (7)            NULL,
    [BusinessCode]                      VARCHAR (5)         NULL,
    [BusinessName]                      VARCHAR (50)        NULL,
    [BusinessDescription]               NVARCHAR (1000)     NULL,
    [BusinessFlashPnLMinThresholdGBP]   DECIMAL (18, 2)     NULL,
    [BusinessFlashPnLMaxThresholdGBP]   DECIMAL (18, 2)     NULL,
    [BusinessFlashManualUpload]         BIT                 NULL,
    [BusinessFlashMurexUpload]          BIT                 NULL,
    [BusinessOrderBy]                   INT                 NULL,
    [DepartmentUId]                     INT                 NULL,
    [DepartmentId]                      INT                 NULL,
    [DepartmentUniqueCode]              CHAR (7)            NULL,
    [DepartmentCode]                    VARCHAR (5)         NULL,
    [DepartmentName]                    VARCHAR (50)        NULL,
    [DepartmentDescription]             NVARCHAR (1000)     NULL,
    [DepartmentFlashPnLMinThresholdGBP] DECIMAL (18, 2)     NULL,
    [DepartmentFlashPnLMaxThresholdGBP] DECIMAL (18, 2)     NULL,
    [DepartmentFlashManualUpload]       BIT                 NULL,
    [DepartmentFlashMurexUpload]        BIT                 NULL,
    [DepartmentOrderBy]                 INT                 NULL,
    [CostCentreUId]                     INT                 NULL,
    [CostCentreId]                      INT                 NULL,
    [CostCentreUniqueCode]              CHAR (7)            NULL,
    [CostCentreCode]                    VARCHAR (5)         NULL,
    [CostCentreName]                    VARCHAR (50)        NULL,
    [CostCentreDescription]             NVARCHAR (1000)     NULL,
    [CostCentreFlashPnLMinThresholdGBP] DECIMAL (18, 2)     NULL,
    [CostCentreFlashPnLMaxThresholdGBP] DECIMAL (18, 2)     NULL,
    [CostCentreFlashManualUpload]       BIT                 NULL,
    [CostCentreFlashMurexUpload]        BIT                 NULL,
    [CostCentreOrderBy]                 INT                 NULL,
    [PortfolioUId]                      INT                 NULL,
    [PortfolioId]                       INT                 NULL,
    [PortfolioUniqueCode]               CHAR (7)            NULL,
    [PortfolioCode]                     VARCHAR (5)         NULL,
    [PortfolioName]                     VARCHAR (50)        NULL,
    [PortfolioDescription]              NVARCHAR (1000)     NULL,
    [PortfolioFlashPnLMinThresholdGBP]  DECIMAL (18, 2)     NULL,
    [PortfolioFlashPnLMaxThresholdGBP]  DECIMAL (18, 2)     NULL,
    [PortfolioFlashManualUpload]        BIT                 NULL,
    [PortfolioFlashMurexUpload]         BIT                 NULL,
    [PortfolioOrderBy]                  INT                 NULL,
    [DeskUId]                           INT                 NULL,
    [DeskId]                            INT                 NULL,
    [DeskUniqueCode]                    CHAR (7)            NULL,
    [DeskCode]                          VARCHAR (5)         NULL,
    [DeskGlobalAccountCode]             CHAR (8)            NULL,
    [DeskName]                          VARCHAR (50)        NULL,
    [DeskDescription]                   NVARCHAR (1000)     NULL,
    [DeskFlashPnLMinThresholdGBP]       DECIMAL (18, 2)     NULL,
    [DeskFlashPnLMaxThresholdGBP]       DECIMAL (18, 2)     NULL,
    [DeskFlashManualUpload]             BIT                 NULL,
    [DeskFlashMurexUpload]              BIT                 NULL,
    [DeskOrderBy]                       INT                 NULL,
    [BookUId]                           INT                 NULL,
    [BookId]                            INT                 NULL,
    [BookUniqueCode]                    CHAR (7)            NULL,
    [BookCode]                          VARCHAR (5)         NULL,
    [BookName]                          VARCHAR (50)        NULL,
    [BookDescription]                   NVARCHAR (1000)     NULL,
    [BookReference]                     VARCHAR (8)         NULL,
    [BookReferenceType]                 VARCHAR (8)         NULL,
    [BookTrader]                        VARCHAR (100)       NULL,
    [BookPnLPackageId]                  INT                 NULL,
    [BookFlashPnLMinThresholdGBP]       DECIMAL (18, 2)     NULL,
    [BookFlashPnLMaxThresholdGBP]       DECIMAL (18, 2)     NULL,
    [BookFlashManualUpload]             BIT                 NULL,
    [BookFlashMurexUpload]              BIT                 NULL,
    [BookAdjustFutures]                 TINYINT             NULL,
    [BookOrderBy]                       INT                 NULL,
    [EmployeeUId]                       INT                 NULL,
    [EmployeeId]                        INT                 NULL,
    [EmployeeUniqueCode]                CHAR (7)            NULL,
    [EmployeeCode]                      VARCHAR (5)         NULL,
    [EmployeeName]                      VARCHAR (50)        NULL,
    [EmployeeDescription]               NVARCHAR (1000)     NULL,
    [EmployeeOrderBy]                   INT                 NULL,
    [ProgrammeUId]                      INT                 NULL,
    [ProgrammeId]                       INT                 NULL,
    [ProgrammeUniqueCode]               CHAR (7)            NULL,
    [ProgrammeCode]                     VARCHAR (5)         NULL,
    [ProgrammeName]                     VARCHAR (50)        NULL,
    [ProgrammeDescription]              NVARCHAR (1000)     NULL,
    [LegacyProgrammeCode]               VARCHAR (8)         NULL,
    [ProgrammeOrderBy]                  INT                 NULL,
    [ProjectUId]                        INT                 NULL,
    [ProjectId]                         INT                 NULL,
    [ProjectUniqueCode]                 CHAR (7)            NULL,
    [ProjectCode]                       VARCHAR (5)         NULL,
    [ProjectName]                       VARCHAR (50)        NULL,
    [ProjectDescription]                NVARCHAR (1000)     NULL,
    [ProjectOrderBy]                    INT                 NULL,
    [ProjectClassificationId]           SMALLINT            NULL,
    [ProjectClassificationCode]         CHAR (3)            NULL,
    [ProjectClassificationName]         VARCHAR (50)        NULL,
    [ProjectTreatmentId]                SMALLINT            NULL,
    [ProjectTreatmentCode]              CHAR (3)            NULL,
    [ProjectTreatmentName]              VARCHAR (50)        NULL,
    [ProjectSystemId]                   SMALLINT            NULL,
    [LegacyProjectCode]                 VARCHAR (8)         NULL,
    [ProjectSystemCode]                 CHAR (3)            NULL,
    [ProjectSystemName]                 VARCHAR (50)        NULL,
    PRIMARY KEY CLUSTERED ([UnitUId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF)
);

